package com.imooc.reader.portal.controller;

import com.imooc.reader.portal.dto.ResponseDTO;
import com.imooc.reader.portal.entity.Category;
import com.imooc.reader.portal.service.CategoryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/categories")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @GetMapping("")
    public ResponseDTO list() {
        List<Category> categories = categoryService.selectAll();
        return new ResponseDTO().put("list", categories);
    }
}
